//
//  HMRetweetView.swift
//  weibo28
//
//  Created by 范英强 on 16/3/25.
//  Copyright © 2016年 范英强. All rights reserved.
//

import UIKit

class HMRetweetView: UIView {
    
    var status: HMStatus?{
        didSet{
            contentLabel.text = "@\(status?.retweeted_status?.user?.name): \(status?.retweeted_status?.text)"
            print(status?.retweeted_status?.pic_urls?.count)
            pictureView.pictureInfo = status?.retweeted_status?.pic_urls
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - 设置视图
    private func setupUI(){
        backgroundColor = RandomColor()
        // 01- 添加控件
        addSubview(contentLabel)
        addSubview(pictureView)
        // 02- 添加约束
        contentLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self).offset(HMStatusCellMargin)
            make.leading.equalTo(self).offset(HMStatusCellMargin)
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentLabel.snp_bottom).offset(HMStatusCellMargin)
            make.leading.equalTo(self).offset(HMStatusCellMargin)
//            make.size.equalTo(CGSize(width: 100, height: 100))
        }
        
        // 约束转发微博 
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(pictureView).offset(HMStatusCellMargin)
        }
        
    }
    
    // MARK: - 懒加载控件
    private lazy var  contentLabel: UILabel = {
        let lab = UILabel(textColor: UIColor.darkGrayColor(), font: 14, maxWidth: SCREENW - HMStatusCellMargin * 2)
        lab.text = "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
        return lab
    }()
    
    // pictureView
    private lazy var pictureView: HMPictureView = HMPictureView()
    
    
    
    
    
    
    
}
